package com.heima.admin.controller.v1;

import com.heima.admin.service.AdChannelService;
import com.heima.model.admin.dtos.ChannelDTO;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "频道管理controller",tags = "频道管理controller")
public class AdChannelController {
    @Autowired
    private AdChannelService adChannelService;

    @PostMapping("list")
    @ApiOperation(value = "根据条件分页查询频道信息",notes = "按照name模糊分页查询，结果按照ord升序排序")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDTO dto){
        return adChannelService.findByNameAndPage(dto);
    }

    @ApiOperation("保存频道信息")
    @PostMapping("save")
    public ResponseResult save(@RequestBody AdChannel channel){
        return adChannelService.insert(channel);
    }

    @ApiOperation("修改频道信息")
    @PostMapping("update")
    public ResponseResult update(@RequestBody AdChannel channel){
        return adChannelService.update(channel);
    }

    @ApiOperation("删除频道信息")
    @GetMapping("del/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return adChannelService.delete(id);
    }



}
